# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: rubicon <rubicon@mailo.com>
pkgname=ocaml-csexp
_pkgname=csexp
pkgver=1.5.1
pkgrel=1
pkgdesc="Parsing and printing of S-expressions in Canonical form"
url="https://github.com/ocaml-dune/csexp"
arch="all !riscv64"  # limited by ocaml aport
license="MIT"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
options="!check"	# requires ppx_expect
makedepends="dune ocaml ocaml-findlib ocamlbuild"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/ocaml-dune/csexp/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build @install
}

check() {
	dune runtest
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml

	# There's just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
b451f380786fda53998f77b1509422d58bb5a51518595e329f625fbf0ca67e597be0c9935de77a10a65216cb4b9ec91579ad51bdeee536795e142e014433d46b  ocaml-csexp-1.5.1.tar.gz
"
